#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include<vector>
#include<algorithm>
#define int long long 
#define PII pair<int,int>
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
const int N = 1e6 + 10, M = 2020, mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int inf = 0x3f3f3f3f3f3f3f3f;
int n, m, k;
int f[N], q[N], fa[N];
vector<int> v;

struct node 
{
	int a, b, w;
}edge[N];

bool cmp(node a, node b) 
{
	return a.w < b.w;
}

int find(int x) 
{
	if (x != fa[x]) fa[x] = find(fa[x]);
	return fa[x];
}

void fun() 
{
	sort(edge + 1, edge + 1 + m, cmp);
	for (int i = 1; i <= n; i++) 
		fa[i] = i;
	for (int i = 1; i <= m; i++)
	{
		int a = edge[i].a, b = edge[i].b, w = edge[i].w;
		a = find(a), b = find(b);
		if (a != b) 
		{
			fa[a] = b;
			v.pb(w);
		}
	}
}

void solve()
{
	cin >> n >> m >> k;
	for (int i = 1; i <= m; i++) 
	{
		int a, b, c;
		cin >> a >> b >> c;
		edge[i] = { a,b,c };
	}
	fun();
	sort(v.begin(), v.end());
	int ans = 0, idx = 1, res = -1;
	for (int i = v.size() - 1; i >= 0; i--) 
	{
		if (ans + idx * v[i] <= k) 
		{
			ans += idx * v[i];
			idx++;
		}
		else 
		{
			res = i;
			break;
		}
	}
	if (res == -1) 
		cout << 0 << endl;
	else 
		cout << v[res] << endl;
}

signed main() 
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int _ = 1;
	//	cin>>_;
	while (_--) 
		solve();
	return 0;
}
